﻿<cfscript>
/** 
* ORM HRWorkload
* 
* @hint "Hibernate persistenter t_hr_workload. 工作量编制额定人数" 
* 
*/ 

component 
	displayname="public.service.orm.senate.HRWorkload" 
	output=false 
	persistent=true 
	selectBeforeUpdate=true dynamicInsert=true dynamicUpdate=true 
	cacheuse="Transactional" 
	entityname="HRWorkload" 
	table="t_hr_workload"
	{
	
	property type="string" name="HRType" column="hrt" fieldtype="id" generator="assigned" hint="编制分类代码";
	
	property type="string" name="TypeName" column="type_name" hint="编制分类名称";
	property type="string" name="TypeNotice" column="type_desc" hint="编制分类说明";
	
	property type="numeric" name="Period" column="type_period" hint="当量学时";

	/**
	* @hint "自定义主键规则"
	*/
	public string function getNextID() output=false {
		
		var nextID = "B" & numberFormat(1, "0_");
		var checkArray = ORMExecuteQuery("select HRType from HRWorkload 
											where HRType like :condition 
											order by HRType desc", { condition="B" & "__" }, { maxResults=1 });

		/* 
			主键生成规则 CHAR(3)
			
			B + 2位流水号
		*/
		if (arrayLen(checkArray)) {
			/* 创建一个追加id */
			nextID = "B" & numberFormat((right(checkArray[1], 2) + 1), "0_");
			
		}
		
		return nextID;
	}
}

</cfscript>
